<html>
<head>
	<meta charset="UTF-8">
	<title>usercontroller</title>
</head>
<body>
	<?php 
require 'Admin/Model/VideoModel.php';
require 'Controller.php';
class VideoController extends Controller{
function __construct(){
parent::__construct();
}
function listvideos(){
	$model=new VideoModel();
	$data=$model->getVideoList();
	
	$this->assign('videos',$data);

	$this->display();
	//return $data;

}
function delvideo(){
	$vid=$_GET['vid'];
	$model= new VideoModel();
	$result=$model->delvideo($vid);
	if($result){
echo "<h2>删除成功！3秒后跳转回视频列表页</h2>";
header("refresh:3;url='admin.php?c=video&m=listvideos'");
//echo "<a href='index.php?c=video&m=listvideos'>返回列表</a>";
	}
	else{
echo "<h2>删除失败！</h2>";
echo "<a href='admin.php?c=video&m=listvideos'>返回列表</a>";
	}
}
function videoform(){
$this->display();
	
}

function addvideo(){
	$data=$_POST;
	$file=$_FILES;
	$model=new VideoModel();
	$result=$model->addvideo($data,$file);
	if ($result) {
		echo "视频添加成功，3秒后返回视频列表页。";
		header("refresh:3;url='admin.php?c=video&m=listvideos'");
	}else{
		echo "视频添加失败，3秒后返回添加页重新添加。";
		header("refresh:3;url='admin.php?c=video&m=videoform'");
	}



}
function editvideo(){
	$vid=$_GET['vid'];
	$model=new VideoModel();
	$data=$model->editvideo($vid);
	$this->assign('video',$data);
	$this->display();
}
function updatevideo(){
	$data=$_POST;
	$file=$_FILES;
	$model=new VideoModel();
	$result=$model->updatevideo($data,$file);
	if($result){
echo "<h2>修改视频成功！3秒后跳转回视频列表页</h2>";
header("refresh:3;url='admin.php?c=video&m=listvideos'");
	}
	else{
echo "<h2>修改视频失败！</h2>";
echo "<a href='admin.php?c=video&m=listvideos'>返回列表</a>";
	}
}

}

	 ?>
</body>
</html>